<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Rep\WarehouseRep;
use Illuminate\Http\Request;

class Warehouse extends Controller
{
    //仓库管理
    protected $rep;

    public function __construct(Request $request)
    {
        $this->rep = new WarehouseRep();
    }

    /**
     * 获取仓库列表
     * @param Request $request
     */
    public function getWarehouseList(Request $request){
        $params = $request->all();
        $data = $this->rep->getWarehouseListRep($params);
        return re(0,$data,'success');
    }

    /**
     * 添加仓库
     * @param Request $request
     */
    public function createWarehouse(Request $request){
        $params = $request->all();
        $data = $this->rep->createWarehouseRep($params);
        return re($data['code'],$data['data'],$data['msg']);
    }

    /**
     * 删除仓库
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function delWarehouse(Request $request){
        $params = $request->all();
        $data = $this->rep->delWarehouseRep($params);
        return re($data['code'],'',$data['msg']);
    }

    /**
     * 添加货架
     * @param Request $request
     */
    public function createGoodsShelf(Request $request){
        $params = $request->all();
        $data = $this->rep->createGoodsShelfRep($params);
        return re($data['code'],'',$data['msg']);
    }

    /***/
    public function  delGoodsShelf(Request $request){
        $params = $request->all();
        $data = $this->rep->delGoodsShelfRep($params);
        return re($data['code']);
    }

    /**
     * 获取仓库分类列表
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function getWarehouseTypeList(Request $request){
        $params = $request->all();
        $data = $this->rep->getWarehouseTypeListRep($params);
        return re(0,$data,'success');
    }
}
